package com.job.Gai_Yian;

/**
 * @author DELL
 * @version 1.0
 * @since 2022-07-01 21:43:25
 */
public class Homework {
    public static void main(String[] args){
        //动态初始化数组  不指定数据
        int[] arr =new int[3];
        //静态初始化  指定数据
        //                   0      1      2     3     4       5
        String[] names={"lucy","张三","王五","李四","null","jack"};
        //length属性  数据个数  也叫数组的长度
        System.out.println(names.length);
        //数组通过下标 来 获取 某个数据 下标index从0开始
        System.out.println(names[0]);
        System.out.println(names[names.length-1]);
        //下标不能越界  0~长度-1
        System.out.println(names[2]);
        System.out.println("发红包！");
        names[2]="王五";
        System.out.println(names[2]);
        //遍历 是最常见的操作，按照某种顺序 逐个访问数据
        for (int i=0;i<names.length;i++){
            System.out.println(i+"\t"+names[i]);
        }
        for (int i=names.length-1;i>=0;i--){
            System.out.println(i+"~~~~~~"+names[i]);
        }
    }
}
